/**
 */
package OBSL.impl;

import OBSL.OBSLPackage;
import OBSL.QualityParameter;
import OBSL.TemporalParameter;
import OBSL.TopLevelSituation;

import java.util.Collection;

import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentEList;
import org.eclipse.emf.ecore.util.InternalEList;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Top Level Situation</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link OBSL.impl.TopLevelSituationImpl#getQualityParameters <em>Quality Parameters</em>}</li>
 *   <li>{@link OBSL.impl.TopLevelSituationImpl#getParameters <em>Parameters</em>}</li>
 *   <li>{@link OBSL.impl.TopLevelSituationImpl#getDefiningIndividualParameter <em>Defining Individual Parameter</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class TopLevelSituationImpl extends SituationImpl implements TopLevelSituation {
	/**
	 * The cached value of the '{@link #getQualityParameters() <em>Quality Parameters</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getQualityParameters()
	 * @generated
	 * @ordered
	 */
	protected EList<QualityParameter> qualityParameters;

	/**
	 * The cached value of the '{@link #getParameters() <em>Parameters</em>}' containment reference list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getParameters()
	 * @generated
	 * @ordered
	 */
	protected EList<TemporalParameter> parameters;

	/**
	 * The cached value of the '{@link #getDefiningIndividualParameter() <em>Defining Individual Parameter</em>}' containment reference.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getDefiningIndividualParameter()
	 * @generated
	 * @ordered
	 */
	protected TemporalParameter definingIndividualParameter;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected TopLevelSituationImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return OBSLPackage.Literals.TOP_LEVEL_SITUATION;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<QualityParameter> getQualityParameters() {
		if (qualityParameters == null) {
			qualityParameters = new EObjectContainmentEList<QualityParameter>(QualityParameter.class, this, OBSLPackage.TOP_LEVEL_SITUATION__QUALITY_PARAMETERS);
		}
		return qualityParameters;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<TemporalParameter> getParameters() {
		if (parameters == null) {
			parameters = new EObjectContainmentEList<TemporalParameter>(TemporalParameter.class, this, OBSLPackage.TOP_LEVEL_SITUATION__PARAMETERS);
		}
		return parameters;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public TemporalParameter getDefiningIndividualParameter() {
		return definingIndividualParameter;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public NotificationChain basicSetDefiningIndividualParameter(TemporalParameter newDefiningIndividualParameter, NotificationChain msgs) {
		TemporalParameter oldDefiningIndividualParameter = definingIndividualParameter;
		definingIndividualParameter = newDefiningIndividualParameter;
		if (eNotificationRequired()) {
			ENotificationImpl notification = new ENotificationImpl(this, Notification.SET, OBSLPackage.TOP_LEVEL_SITUATION__DEFINING_INDIVIDUAL_PARAMETER, oldDefiningIndividualParameter, newDefiningIndividualParameter);
			if (msgs == null) msgs = notification; else msgs.add(notification);
		}
		return msgs;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public void setDefiningIndividualParameter(TemporalParameter newDefiningIndividualParameter) {
		if (newDefiningIndividualParameter != definingIndividualParameter) {
			NotificationChain msgs = null;
			if (definingIndividualParameter != null)
				msgs = ((InternalEObject)definingIndividualParameter).eInverseRemove(this, EOPPOSITE_FEATURE_BASE - OBSLPackage.TOP_LEVEL_SITUATION__DEFINING_INDIVIDUAL_PARAMETER, null, msgs);
			if (newDefiningIndividualParameter != null)
				msgs = ((InternalEObject)newDefiningIndividualParameter).eInverseAdd(this, EOPPOSITE_FEATURE_BASE - OBSLPackage.TOP_LEVEL_SITUATION__DEFINING_INDIVIDUAL_PARAMETER, null, msgs);
			msgs = basicSetDefiningIndividualParameter(newDefiningIndividualParameter, msgs);
			if (msgs != null) msgs.dispatch();
		}
		else if (eNotificationRequired())
			eNotify(new ENotificationImpl(this, Notification.SET, OBSLPackage.TOP_LEVEL_SITUATION__DEFINING_INDIVIDUAL_PARAMETER, newDefiningIndividualParameter, newDefiningIndividualParameter));
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd, int featureID, NotificationChain msgs) {
		switch (featureID) {
			case OBSLPackage.TOP_LEVEL_SITUATION__QUALITY_PARAMETERS:
				return ((InternalEList<?>)getQualityParameters()).basicRemove(otherEnd, msgs);
			case OBSLPackage.TOP_LEVEL_SITUATION__PARAMETERS:
				return ((InternalEList<?>)getParameters()).basicRemove(otherEnd, msgs);
			case OBSLPackage.TOP_LEVEL_SITUATION__DEFINING_INDIVIDUAL_PARAMETER:
				return basicSetDefiningIndividualParameter(null, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
			case OBSLPackage.TOP_LEVEL_SITUATION__QUALITY_PARAMETERS:
				return getQualityParameters();
			case OBSLPackage.TOP_LEVEL_SITUATION__PARAMETERS:
				return getParameters();
			case OBSLPackage.TOP_LEVEL_SITUATION__DEFINING_INDIVIDUAL_PARAMETER:
				return getDefiningIndividualParameter();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
			case OBSLPackage.TOP_LEVEL_SITUATION__QUALITY_PARAMETERS:
				getQualityParameters().clear();
				getQualityParameters().addAll((Collection<? extends QualityParameter>)newValue);
				return;
			case OBSLPackage.TOP_LEVEL_SITUATION__PARAMETERS:
				getParameters().clear();
				getParameters().addAll((Collection<? extends TemporalParameter>)newValue);
				return;
			case OBSLPackage.TOP_LEVEL_SITUATION__DEFINING_INDIVIDUAL_PARAMETER:
				setDefiningIndividualParameter((TemporalParameter)newValue);
				return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
			case OBSLPackage.TOP_LEVEL_SITUATION__QUALITY_PARAMETERS:
				getQualityParameters().clear();
				return;
			case OBSLPackage.TOP_LEVEL_SITUATION__PARAMETERS:
				getParameters().clear();
				return;
			case OBSLPackage.TOP_LEVEL_SITUATION__DEFINING_INDIVIDUAL_PARAMETER:
				setDefiningIndividualParameter((TemporalParameter)null);
				return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
			case OBSLPackage.TOP_LEVEL_SITUATION__QUALITY_PARAMETERS:
				return qualityParameters != null && !qualityParameters.isEmpty();
			case OBSLPackage.TOP_LEVEL_SITUATION__PARAMETERS:
				return parameters != null && !parameters.isEmpty();
			case OBSLPackage.TOP_LEVEL_SITUATION__DEFINING_INDIVIDUAL_PARAMETER:
				return definingIndividualParameter != null;
		}
		return super.eIsSet(featureID);
	}

} //TopLevelSituationImpl
